package com.luyuan.crm.product.service.impl;

import java.io.Serializable;
import java.util.List;

import org.hibernate.criterion.Order;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import com.luyuan.crm.product.model.ProductType;
import com.luyuan.crm.product.service.ProductTypeService;
import com.ruijie.foundation.dao.support.HibernateEntityDao;
import com.ruijie.foundation.query.Page;
import com.ruijie.foundation.query.criteria.CriteriaQueryTemplate;
import com.ruijie.foundation.query.criteria.CriteriaTemplate;

@SuppressWarnings("unchecked")
public class ProductTypeServiceImpl extends HibernateEntityDao<ProductType> implements ProductTypeService {

    @Override
    public Page pagedQuery(CriteriaTemplate criteria, int pageNo, int pageSize, List<Order> orders) {
        CriteriaQueryTemplate qt = new CriteriaQueryTemplate(getSessionFactory());
        return qt.pagedQuery(criteria, pageNo, pageSize, orders);
    }

    @Override
    public ProductType getProductTypeById(Serializable id) {
        return safeGet(id);
    }

    @Override
    public void updateProductType(ProductType product) {
        this.update(product);
    }

    @Override
    public void addProductTypeModel(ProductType product) {
        this.save(product);
    }

    @Override
    @Transactional(isolation = Isolation.READ_COMMITTED)
    public void deleteProductTypeById(Serializable id) {
        this.remove(id);
    }

    @Override
    public void batchDeleteProductType(Serializable[] ids) {
        this.remove(ids);
    }

}
